 begintownscript;

 variables;

 int i,j,k,r1,choice;

 body;

 beginstate INIT_STATE;
	set_character_pose(6,3);
	set_flag(8,0,0);
	set_crime_tolerance(1);
	set_level(6,20);
	set_level(7,25);
	set_level(8,25);
	set_level(9,25);
	set_level(10,25);
	add_char_to_group(6,1);

	if (get_flag(7,15) == 1)
		activate_hidden_group(3);

break;

 beginstate START_STATE;

	if ((get_flag(8,2) == 1) && (party_can_see_loc(8,8)))
		set_char_status(1001,29,15,1,0);


break;

 beginstate EXIT_STATE;

break;

 beginstate 10;
	move_to_new_town(7,25,16);
break;

 beginstate 11;
	if (get_flag(8,0) == 0) {
		message_dialog("You notice that this statue has two deep holes on its neck. You place your fingers in there and the door next to the statue flies open.","");
		set_terrain(13,8,17);
		set_flag(8,0,1);
		play_sound(58);
}
break;

 beginstate 12;
	if (get_flag(7,15) == 1 && get_flag(8,1) == 0) {
		reset_dialog();
		add_dialog_str(0,"You have reached Mosadorl in his private chambers. He bares his fangs to the sight of you and hisses. _Curse you adventurers! It wasn't even an army this time! Only petty adventurers! But do not think I was unprepared!_",0);
		add_dialog_str(1,"_Oh, NO! I had plenty of years to get ready for this to happened again! You think you caught me? Fools!_",0);
		add_dialog_str(2,"The vampire raises his hands, you are too late to stop him...",0);
		add_dialog_choice(0,"OK.");
		run_dialog(1);
		set_state_continue(13);
}
break;

 beginstate 13;
	set_total_visibility(1);
	force_view_center(16,20);
force_instant_terrain_redraw();
	pause(3);
	text_bubble_on_char(13,"Curse you!");
force_instant_terrain_redraw();
	pause(3);
	put_straight_zap(20,22,19,19,0);
	put_straight_zap(20,22,13,19,0);
	put_straight_zap(20,22,16,22,0);
	put_boom_on_space(19,19,0,1);
	put_boom_on_space(13,19,0,1);
	put_boom_on_space(16,22,0,1);
force_instant_terrain_redraw();
	run_animation_sound(51);
	pause(3);
	play_sound(108);
	pause(1);
	set_terrain(19,19,126);
	set_terrain(13,19,127);
	set_terrain(16,22,126);
	set_terrain(14,20,137);
force_instant_terrain_redraw();
	play_sound(108);
	set_terrain(18,19,138);
	set_terrain(19,20,125);
	set_terrain(20,20,126);
	set_terrain(20,21,127);
	set_terrain(19,21,126);
	set_terrain(17,22,138);
	set_terrain(19,22,126);
	set_terrain(19,23,125);
	set_terrain(12,22,126);
	set_terrain(12,23,125);
	set_terrain(13,24,125);
	set_terrain(16,21,126);
force_instant_terrain_redraw();
	play_sound(108);
	set_terrain(16,23,127);
	set_terrain(17,23,126);
	set_terrain(15,23,126);
	set_terrain(13,22,138);
	set_terrain(13,20,127);
	set_terrain(20,23,127);
	set_terrain(19,24,126);
	set_terrain(13,19,126);
	set_terrain(13,21,125);
	set_terrain(15,19,138);
	set_terrain(12,21,126);
force_instant_terrain_redraw();
	text_bubble_on_char(13,"");
force_instant_terrain_redraw();
	text_bubble_on_char(13,"Curse all of you!");
force_instant_terrain_redraw();
	pause(3);
	put_effect_on_char(13,9,1,0);
	run_animation_sound(163);
force_instant_terrain_redraw();
	pause(1);
	erase_char(13);
	set_total_visibility(0);
	pause(5);
	message_dialog("Well, the vampire is gone. The collapsing of the roof stops. You doubt Mosadorl would destroy his own tower, if he was planing on returning. Still, maybe his plan was just to kill you with the collapsing roof, or block your entry to his chambers."," Lucky for you though, one pillar survived, it is barely holding the roof together. You begin to think your work here is done and you plan to leave. Then you see a book lying in the rubble and hear footsteps. You are not alone.");
	activate_hidden_group(2);
	activate_hidden_group(1);
	set_flag(8,1,3);
force_instant_terrain_redraw();
break;

 beginstate 14;
	if (get_flag(8,1) == 3) {
		set_terrain(13,8,17);
		set_flag(8,1,5);
		message_dialog("Just when you think your troubles are over you hear a mad shrieking cry from the hallway up ahead. Something has come lose.","");
		set_attitude(6,10);
		set_char_status(6,29,-15,1,0);
}
break;

 beginstate 15;
	if (get_flag(8,2) == 0 && get_flag(8,1) != 5) {
		set_char_status(1001,29,15,1,0);
		message_dialog("That's odd. You find an imp encaged in a forcecage, and apparently this is no ordinary forcecage. The imps expression is solid. but its eyelids are open and the eyes are moving rapidly back and forth.","It's like the imp isn't in control of its own body.");
		set_flag(8,2,1);
}
break;

 beginstate 16;
	reset_dialog();
	add_dialog_str(0,"You find a book lying on a pedestal. It is worn and probably very old. The cover reads. _Mosadorl_.",0);
	add_dialog_choice(0,"Read the Book.");
	add_dialog_choice(1,"Ignore the Book.");
	choice = run_dialog(1);

	if (choice == 1)
		message_dialog("The book is not magical, it starts with a phrase. _Your name is Mosadorl, this book is written, so that you will never forget._ It is a diary of some sort. Within its pages lies the story of Mosadorl the vampire. Details of his actual life are vague.","The book contains more detailed facts when it entries come close to the present. Apparently Mosadorl has been trying to find a way to seal himself off from the rest of the world, by using Vahnatai magics. So far he's had no luck. You close the book.");
break;

 beginstate 17;
	if (get_flag(8,3) == 0) {
		message_dialog("You seem to stumbled upon Mosadorl's private altar. It is, as you would suspect, made of black obsidian. The aura it emits, however, is not dark. It isn't a holy aura either.","You are positive that the altar emits an aura. Perhaps the deity, if any, is a neutral one.");
		set_flag(8,3,1);
}
break;

 beginstate 18;
	if (get_flag(8,4) == 0) {
		message_dialog("You recognize the crystal in front of you. Among other powerful wizards, these kinds of crystals are favored by the Vahnatai.","You have no idea what it does, and sensing powerful magical protections placed upon it, you decide not to touch it.");
		set_flag(8,4,1);
}
break;

 beginstate 19;
	print_str_color("What do you know, this bookcase is just an illusion.",2);
break;

 beginstate 20;
	if (get_flag(8,5) == 0) {
		message_dialog("Great, looks like you've encountered a very powerful shade. And to top it off, it seems crazed. It howls and attacks you.","");
 		set_flag(8,5,1);
}
 break;

 beginstate 21;
	if (get_flag(8,1) != 3 && get_flag(8,6) == 0) {
		reset_dialog();
		add_dialog_str(0,"This is Mosadorl's sarcophagus. The room you are in is dreadfully foreboding. You get the feeling you are being watched.",0);
		add_dialog_str(1,"Nonetheless, what do you do with the sarcophagus?",0);
		add_dialog_choice(0,"Open it.");
		add_dialog_choice(1,"Nothing.");
		choice = run_dialog(1);

	if (choice == 1) {
		message_dialog("The sarcophagus opens with a creak. Naturally there is no body to be found. You do, however find an ancient tome strapped in leather. You open the book to see what it contains. You are surprised about the content.","You see instructions on several quite powerful holy rituals, most of them are unknown to you. You pocket the book. it might contain useful information.");
		set_flag(8,6,1);
		change_spec_item(9,1);
		message_dialog("You close the sarcophagus, and quickly turn around. You could have sworn you heard something move behind you, and next to you.","");
		activate_hidden_group(1);
		activate_hidden_group(2);
}
	if (choice == 2)
		block_entry(1);
}
 break;

 beginstate 22;
	if ((get_flag(8,1) == 3) && (get_flag(8,6) == 0)) {
		message_dialog("The vampire must have dropped this book. It is an ancient tome strapped in leather. You open the book to see what it contains. You are surprised about the content.","You see instructions on several quite powerful holy rituals, most of them are unknown to you. You pocket the book. it might contain useful information.");
		set_flag(8,6,1);
		change_spec_item(9,1);
}
 break;